<?php

  /**
   * Provides server specific methods.<br />
   * These functions are only available when running PHP as an Apache module.<br />
   *
   * @version 1.1 beta
   * @author Dany Mottier
   *
   * @see <a href="http://fr2.php.net/manual/en/book.apache.php">online documentation</a>
   */
  abstract class Apache {

    /**
     * Translate string from ASCII to EBCDIC.<br />
     * It is an Apache-specific function which is available only on EBCDIC based
     * operating systems (OS/390, BS2000).<br />
     * It translates the ASCII encoded string $string to its equivalent EBCDIC
     * representation (binary safe), and returns the result.<br />
     *
     * @param string $string The ASCII string that will be translated.
     *
     * @return integer The EBCDIC representation of an ASCII string.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.ascii2ebcdic.php">ascii2ebcdic()</a>
     */
    public function AsciiToEBCDIC($string) {
      return ascii2ebcdic($string);
    }

    /**
     * Terminate apache process after this request.<br />
     * Will register the Apache process executing the current PHP request for
     * termination once execution of PHP code is completed.<br />
     * It may be used to terminate a process after a script with high memory
     * consumption has been run as memory will usually only be freed internally
     * but not given back to the operating system.<br />
     *
     * @return boolean Returns TRUE if PHP is running as an Apache 1 module,
     * the Apache version is non-multithreaded, and the child_terminate PHP
     * directive is enabled (disabled by default). If these conditions are not
     * met, FALSE is returned.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-child-terminate.php">apache_child_terminate()</a>
     */
    public function ChildTerminate() {
      return apache_child_terminate();
    }

    /**
     * Fetch all HTTP request headers.<br />
     * Fetches all HTTP requests from the current request.<br />
     * This function is only supported when PHP is installed as an Apache module.<br />
     *
     * @return mixed An associative array of all the HTTP headers in the current
     * request, or FALSE on failure.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-request-headers.php">apache_request_headers()</a>
     */
    public function FetchRequestHeaders() {
      return apache_request_headers();
    }

    /**
     * Fetch all HTTP response headers.<br />
     *
     * @return mixed An array of all Apache response headers on success, or
     * FALSE on failure.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-response-headers.php">apache_response_headers()</a>
     */
    public function FetchResponseHeaders() {
      return apache_response_headers();
    }

    /**
     * Fetch all HTTP request headers.<br />
     * Fetches all HTTP headers from the current request.<br />
     * This function is an alias for FetchRequestHeaders().<br />
     * Please read the FetchRequestHeaders() documentation for more information
     * on how this function works.<br />
     * This function is only supported when PHP is installed as an Apache module.<br />
     *
     * @return mixed An associative array of all the HTTP headers in the current
     * request, or FALSE on failure.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.getallheaders.php">getallheaders()</a>
     */
    public function FetchAllHeaders() {
      return getallheaders();
    }

    /**
     * Get a list of loaded Apache modules.<br />
     * @return array An array of loaded Apache modules.<br /><br />
     * @see <a href="http://fr2.php.net/manual/en/function.apache-get-modules.php">apache_get_modules()</a>
     */
    public function GetModules() {
      return apache_get_modules();
    }

    /**
     * Fetch Apache version.<br />
     * @return mixed Returns the Apache version on success, or FALSE on failure.<br /><br />
     * @see <a href="http://fr2.php.net/manual/en/function.apache-get-version.php">apache_get_version()</a>
     */
    public function GetVersion() {
      return apache_get_version();
    }

    /**
     * Perform a partial request for the specified URI and return all info about it.<br />
     * This performs a partial request for a URI.<br />
     * It goes just far enough to obtain all the important information about the given resource.<br />
     * This function is only supported when PHP is installed as an Apache module.<br />
     *
     * @param string $filename The filename (URI) that's being requested.
     *
     * @return URIInformations Returns an object with all informations.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-lookup-uri.php">apache_lookup_uri()</a>
     */
    public function LookupURI($filename) {
      return new URIInformations(apache_lookup_uri($filename));
    }

    /**
     * Reset the Apache write timer.<br />
     * Resets the Apache write timer, which defaults to 300 seconds.<br />
     * With set_time_limit(0); ignore_user_abort(true) and periodic
     * Apache::ResetTimeout() calls, Apache can theoretically run forever.<br />
     *
     * @return boolean Returns TRUE on success or FALSE on failure.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-reset-timeout.php">apache_reset_timeout()</a>
     */
    public function ResetTimeout() {
      return apache_reset_timeout();
    }

    /**
     * Perform an Apache sub-request.<br />
     * It is an Apache-specific function which is similar to
     * <!--#include virtual...--> in mod_include.<br />
     * It performs an Apache sub-request.<br />
     * It is useful for including CGI scripts or .shtml files, or anything else
     * that you would parse through Apache. Note that for a CGI script, the
     * script must generate valid CGI headers.<br />
     * At the minimum that means it must generate a Content-type header.
     * To run the sub-request, all buffers are terminated and flushed to the
     * browser, pending headers are sent too.<br />
     * This function is only supported when PHP is installed as an Apache module.<br />
     *
     * @param string $filename The file that the virtual command will be performed on.
     *
     * @return boolean Performs the virtual command on success, or returns
     * FALSE on failure.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.virtual.php">virtual()</a>
     */
    public function Virtual($filename) {
      return virtual($filename);
    }

    // -------------------------------------------------------------------------

    /**
     * Get an Apache subprocess_env variable.<br />
     * @param string $variable The Apache environment variable.
     * @param boolean $walk_to_top Whether to get the top-level variable
     * available to all Apache layers.
     * @return mixed The value of the Apache environment variable on success,
     * or FALSE on failure.<br /><br />
     * @see <a href="http://fr2.php.net/manual/en/function.apache-getenv.php">apache_getenv()</a>
     */
    public function getEnvironmentVariable($variable, $walk_to_top = FALSE) {
      return apache_getenv($variable, $walk_to_top);
    }

    /**
     * Get apache request notes.<br />
     * This function is a wrapper for Apache's table_get and table_set.<br />
     * It edits the table of notes that exists during a request.<br />
     * The table's purpose is to allow Apache modules to communicate.<br />
     * The main use for SetNote() is to pass information from one module to
     * another within the same request.<br />
     *
     * @param string $name The name of the note.
     *
     * @return mixed Returns the current value of note $name.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-note.php">apache_note()</a>
     */
    public function getNote($name) {
      return apache_note($name);
    }

    /**
     * Set an Apache subprocess_env variable.<br />
     *
     * @param string $variable The environment variable that's being set.
     * @param string $value The new variable  value.
     * @param boolean $walk_to_top Whether to set the top-level variable
     * available to all Apache layers.
     *
     * @return boolean Returns TRUE on success or FALSE on failure.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-setenv.php">apache_setenv()</a>
     */
    public function setEnvironmentVariable($variable, $value, $walk_to_top = FALSE) {
      return apache_setenv($variable, $value, $walk_to_top);
    }

    /**
     * Set apache request notes.<br />
     * This function is a wrapper for Apache's table_get and table_set.<br />
     * It edits the table of notes that exists during a request.<br />
     * The table's purpose is to allow Apache modules to communicate.<br />
     * The main use for SetNote() is to pass information from one module to
     * another within the same request.<br />
     *
     * @param string $name The name of the note.
     * @param string $value The value of the note.
     *
     * @return mixed Returns the previous value of note $name.<br />
     * If the note cannot be retrieved, FALSE is returned.<br /><br />
     *
     * @see <a href="http://fr2.php.net/manual/en/function.apache-note.php">apache_note()</a>
     */
    public function setNote($name, $value) {
      return apache_note($name, $value);
    }

  }

?>
